package modules

import (
	"gorm.io/gorm"
	"time"
)

type Post struct {
	gorm.Model
	ID          int       `gorm:"primary_key;AUTO_INCREMENT"`
	PostID      int64     `gorm:"column:post_id;AUTO_INCREMENT;index:idx_post_id"`
	AuthorID    int64     `gorm:"column:author_id;index:idx_author_id"`
	CommunityID int64     `gorm:"column:community_id;index:idx_community_id" json:"community_id" binding:"required"`
	Status      int       `gorm:"column:status"`
	Title       string    `gorm:"column:title" json:"title" binding:"required"`
	Content     string    `gorm:"column:content" json:"content" binding:"required"`
	CreateTime  time.Time `gorm:"type:TIMESTAMP;NOT NULL;default:CURRENT_TIMESTAMP"`
	UpdateTime  time.Time `gorm:"type:TIMESTAMP;NOT NULL;default:CURRENT_TIMESTAMP"`
}

func (Post) TableName() string {
	return "post"
}
